using DaoHang.Models;

namespace DaoHang.Services
{
    /// <summary>
    /// 分类服务接口，定义分类相关的业务操作
    /// </summary>
    public interface ICategoryService
    {
        /// <summary>
        /// 获取所有分类列表
        /// </summary>
        /// <returns>分类列表</returns>
        Task<List<Category>> GetAllCategoriesAsync();

        /// <summary>
        /// 根据ID获取分类详情
        /// </summary>
        /// <param name="id">分类ID</param>
        /// <returns>分类信息</returns>
        Task<Category?> GetCategoryByIdAsync(int id);

        /// <summary>
        /// 添加新分类
        /// </summary>
        /// <param name="category">分类信息</param>
        /// <returns>添加的分类</returns>
        Task<Category> AddCategoryAsync(Category category);

        /// <summary>
        /// 创建新分类
        /// </summary>
        /// <param name="category">分类信息</param>
        /// <returns>是否创建成功</returns>
        Task<bool> CreateCategoryAsync(Category category);

        /// <summary>
        /// 更新分类信息
        /// </summary>
        /// <param name="category">分类信息</param>
        /// <returns>更新的分类</returns>
        Task<Category> UpdateCategoryAsync(Category category);

        /// <summary>
        /// 删除分类
        /// </summary>
        /// <param name="id">分类ID</param>
        /// <returns>删除是否成功</returns>
        Task<bool> DeleteCategoryAsync(int id);

        /// <summary>
        /// 检查分类名称是否已存在
        /// </summary>
        /// <param name="name">分类名称</param>
        /// <param name="excludeId">排除的分类ID（用于更新时检查）</param>
        /// <returns>是否已存在</returns>
        Task<bool> IsCategoryNameExistsAsync(string name, int? excludeId = null);

        /// <summary>
        /// 获取分类下的网站数量
        /// </summary>
        /// <param name="categoryId">分类ID</param>
        /// <returns>网站数量</returns>
        Task<int> GetWebsiteCountByCategoryAsync(int categoryId);
    }
} 